package com.guigu.www.erp.yinjiaxiong.controller;

import com.guigu.www.erp.common.pojo.*;
import com.guigu.www.erp.dehao.pojo.User;
import com.guigu.www.erp.yinjiaxiong.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * 入库管理
 */
@RequestMapping("inputmanagerController")
@RestController
public class YJXinputmanagerController {

    @Autowired
    MApplyService2 mApplyService;

    //产品档案Service
    @Autowired
    YJXDFileService yjxdFileService;

    //入库Service
    @Autowired
    YJXSGatherService yjxsGatherService;

    //入库明细Service
    @Autowired
    YJXsGatherDetailsService yjXsGatherDetails;


    //出库Service
    @Autowired
    YJXSPayService yjxsPayService;

    //出库明细
    @Autowired
    YJXsPayDetailsService yjXsPayDetailsServicel;


    //存储单元表
    @Autowired
    YJXSCellService yjxsCellService;

    /*
    入库申请登记（添加按钮）
    获取 产品生产计划表（m_apply）)审核标记为1 审核通过的查出来
     */
    @GetMapping("getMapply1")
    public List<MApply> getMapply1() {
        List<MApply> list = mApplyService.getMapply1();
        //System.out.println("listmApply====" + list);
        return list;
    }

    //查询档案表 审核记录通过的数据
    @GetMapping("getFile1")
    public List<DFile> getFile1() {
        return yjxdFileService.getFile1();
    }

    @RequestMapping("getSGather0")
    public PageVo<SGather> getSGather0(SGather sGather, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        //System.out.println("sGather====" + sGather);
        //System.out.println(pageNum + ",," + pageSize);
        User loginUser = (User) request.getSession().getAttribute("loginUser");
        if (loginUser.getRole().getRoleId()==4){
            return null;
        }
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sGather != null) {
            request.getSession().setAttribute("sGather1", sGather);
        } else {
            sGather = (SGather) request.getSession().getAttribute("sGather1");
        }

        return yjxsGatherService.getSGather0(sGather, pageNum, pageSize);
    }

    //查询所有入库表
    @RequestMapping("getAllsGather")
    public PageVo<SGather> getAllsGather(SGather sGather, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        //System.out.println("sGather====" + sGather);
        //System.out.println(pageNum + ",," + pageSize);
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sGather != null) {
            request.getSession().setAttribute("sGather2", sGather);
        } else {
            sGather = (SGather) request.getSession().getAttribute("sGather2");
        }

        return yjxsGatherService.getAllsGather(sGather, pageNum, pageSize);
    }


    //添加入库表 与 入库明细表
    @PostMapping("insertSGather")
    public int insertSGather(@RequestBody(required = false) SGather sGather, HttpServletRequest request) {
        System.out.println(sGather);
       int i1 = yjxsGatherService.insertSGather(sGather);
        //循环添加明细表 sGather.getId()获取上一条自增主键
        for (int i = 0; i < sGather.getSGatherDetails().size(); i++) {
            sGather.getSGatherDetails().get(i).setParentId(sGather.getId());
            int n = yjXsGatherDetails.insertsGatherDetails(sGather.getSGatherDetails().get(i));
        }
        // System.out.println("自增id*************"+sGather.getId());
        return i1;
    }


    //添加入库明细表
//    @PostMapping("sGatherDetails")
//    public int insertsGatherDetails(@RequestBody(required = false) SGatherDetails sGatherDetails,HttpServletRequest request){
//        System.out.println(sGatherDetails);
//        Integer n = (Integer) request.getSession().getAttribute("i");
//        System.out.println("自增id*************"+n);
//        int i= yjXsGatherDetails.insertsGatherDetails(sGatherDetails);
//        return i;
//    }

    //通过入库表id  查询该id 下的细节表 gather_tag标记为未调度（gather_tag=1）的数据
    @GetMapping("BysGatherIdquerysGatherDetails")
    public List<SGatherDetails> BysGatherIdquerysGatherDetails(Integer id) {
        System.out.println("入库表id==="+id);
        System.out.println("入库明细表==="+yjXsGatherDetails.ByparentIDquery(id));
        return yjXsGatherDetails.ByparentIDquery(id);
    }

    //通过入库表id  查询该id 下的细节表 gather_tag标记为已调度（gather_tag=2）的数据
    @GetMapping("BysGatherIdquerysGatherDetailsgatherTag2")
    public List<SGatherDetails> BysGatherIdquerysGatherDetailsgatherTag2(Integer id) {
        return yjXsGatherDetails.BysGatherIdquerysGatherDetailsgatherTag2(id);
    }


    //修改入库表状态
    @GetMapping("updatesGathercheckTag")
    public int updatesGathercheckTag(SGather sGather) {
        return yjxsGatherService.updatesGathercheckTag(sGather);
    }


    //出库表添加值
    @PostMapping("insertSPay")
    public int insertSPay(@RequestBody(required = false) SPay sPay) {
        int n = yjxsPayService.insertSGather(sPay);
        //循环该出库明细表加值
        for (int j = 0; j < sPay.getSPayDetails().size(); j++) {
            sPay.getSPayDetails().get(j).setParentId(sPay.getId());
            yjXsPayDetailsServicel.insertsPayDetails(sPay.getSPayDetails().get(j));
        }
        return n;
    }


    //添加出库明细表
//    @PostMapping("sPayDetails")
//    public int sPayDetails(@RequestBody(required = false) SPayDetails sPayDetails){
//        System.out.println(sPayDetails);
//        int i= yjXsPayDetailsServicel.insertsPayDetails(sPayDetails);
//        return i;
//    }


    //查询出 出库审核标志未审核（0）的数据
    @RequestMapping("getsPaycheck_tag0")
    public PageVo<SPay> getsPaycheck_tag0(SPay sPay, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        User loginUser = (User) request.getSession().getAttribute("loginUser");
        if (loginUser.getRole().getRoleId()==4){
            return null;
        }
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sPay != null) {
            request.getSession().setAttribute("sPay1", sPay);
        } else {
            sPay = (SPay) request.getSession().getAttribute("sPay1");
        }

        return yjxsPayService.getsPaycheck_tag0(sPay, pageNum, pageSize);
    }


    //通过出库表id  查询出库明细表
    @GetMapping("BySpayIdqueryspayDetails")
    public List<SPayDetails> BySpayIdqueryspayDetails(Integer id) {
        return yjXsPayDetailsServicel.BySpayIdqueryspayDetails(id);
    }

    //修改出库表的审核标志 该为已通过（1）/不通过（2）
    @GetMapping("updateSPaycheckTag")
    public int updateSPaycheckTag(SPay sPay) {
        return yjxsPayService.updateSPaycheckTag(sPay);
    }

    //查询所有的出库表
    @RequestMapping("getAllSPay")
    public PageVo<SPay> getAllSPay(SPay sPay, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sPay != null) {
            request.getSession().setAttribute("sPay3", sPay);
        } else {
            sPay = (SPay) request.getSession().getAttribute("sPay3");
        }

        return yjxsPayService.getAllSPay(sPay, pageNum, pageSize);
    }


    //定制入库单  把入库登记申请标记通过（1） 和库存标志（store_tag=1） 的查询出来
    @RequestMapping("getSGather1")
    public PageVo<SGather> getSGather1(SGather sGather, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sGather != null) {
            request.getSession().setAttribute("sGather1", sGather);
        } else {
            sGather = (SGather) request.getSession().getAttribute("sGather1");
        }

        return yjxsGatherService.getSGather1(sGather, pageNum, pageSize);
    }

    /**
     * @param id        入库明细表id
     * @param productId 产品id
     * @param addAmount 要调度要添加的产品数量
     * @return
     */
    //点击调度  根据产品明细中的产品id  查询档案表该产品id是否  有设计库存分配标准（design_cell_tag） 是否设计  如果  未设计（0）不能调度  设计（1）修改相关信息
    @GetMapping("ByproductIdqueryIsdesignCellTag")
    public int ByproductIdqueryIsdesignCellTag(Integer id, String productId, Integer parentId, Integer addAmount) {
        String n = yjxdFileService.ByproductIdqueryDesignCellTag(productId);
        if ("1".equals(n)) {
            //已设计
            //1.修改明细表
            int m = yjXsGatherDetails.ByprimaryKeyupdategatherTag(id);
            // 2.往 修改入库表添加调度时间和调度人
            int j = yjxsGatherService.updateSGatherattemper(parentId);
            //3. 修改库存单元里面的 库存数量 （当前存储量）+（本次存入的数量）
            int aa = yjxsCellService.addAmount(addAmount, productId);  //等复核成功以后才修改数量
            int num = 0;
            //4.判断该入库表中是否所有 明细都已经调度  如果全调度修改该入库表的库存标记为已调度
            List<SGatherDetails> sGatherDetails = yjXsGatherDetails.ByparentIDquery(parentId);
            for (int i = 0; i < sGatherDetails.size(); i++) {
                if (sGatherDetails.get(i).getGatherTag() == "2") {
                    num++;
                }
            }

            if (sGatherDetails.size() == num) {
                //如果全都已调度  则修改入库表的入库标记为已调度
                int k = yjxsGatherService.ByIdupdatesGatherstoreTag(parentId);
            }
        }
        return Integer.parseInt(n);
    }

    //定制入库单  把入库登记申请标记通过（1） 和库存标志（store_tag=1） 的查询出来
    @RequestMapping("getSpaycheckTag1storeTag1")
    public PageVo<SPay> getSpaycheckTag1storeTag1(SPay sPay, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sPay != null) {
            request.getSession().setAttribute("sPay5", sPay);
        } else {
            sPay = (SPay) request.getSession().getAttribute("sPay5");
        }

        return yjxsPayService.getSpaycheckTag1storeTag1(sPay, pageNum, pageSize);
    }


    //通过出库表id  查询该id 下的细节表
    @GetMapping("ByPayIdquerySayDetails")
    public List<SPayDetails> ByPayIdquerySayDetails(Integer id) {
        return yjXsPayDetailsServicel.ByPayIdquerySayDetails(id);
    }


    /**
     * @param id        出库明细表id
     * @param productId 产品id
     * @return
     */
    //点击调度  根据产品明细中的产品id  查询档案表该产品id是否  有设计库存分配标准（design_cell_tag） 是否设计  如果  未设计（0）不能调度  设计（1）修改相关信息
    @GetMapping("ByproductIdqueryPayIsdesignCellTag")
    public int ByproductIdqueryPayIsdesignCellTag(Integer id, String productId, Integer parentId, Integer reduceAmount) {
        String n = yjxdFileService.ByproductIdqueryDesignCellTag(productId);
        if ("1".equals(n)) {
            //已设计
            //1.修改明细表
            int m = yjXsPayDetailsServicel.ByprimaryKeyupdatePaygatherTag(id);
            // 2.往 修改入库表添加调度时间和调度人
            int j = yjxsPayService.updateSGatherattemper(parentId);
            //3. 修改库存单元里面的 库存数量 （当前存储量）+（本次存入的数量）
            reduceAmount = 0 - reduceAmount;
            int aa = yjxsCellService.addAmount(reduceAmount, productId);
            int num = 0;
            //4.判断该入库表中是否所有 明细都已经调度  如果全调度修改该入库表的库存标记为已调度
            List<SPayDetails> sPayDetails = yjXsPayDetailsServicel.ByparentIDquery(parentId);
            for (int i = 0; i < sPayDetails.size(); i++) {
                if (sPayDetails.get(i).getPayTag() == "2") {
                    num++;
                }
            }

            if (sPayDetails.size() == num) {
                //如果全都已调度  则修改入库表的入库标记为已调度
                int k = yjxsPayService.ByIdupdatesGatherstoreTag(parentId);
            }
        }
        return Integer.parseInt(n);
    }

    //    入库登记 把入库表库存标志为已调度（2）的数据查询出来
    @GetMapping("getstoreTag2")
    public PageVo<SGather> getstoreTag2(SGather sGather, Integer pageNum, Integer pageSize, HttpServletRequest request) {

        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sGather != null) {
            request.getSession().setAttribute("sGather6", sGather);
        } else {
            sGather = (SGather) request.getSession().getAttribute("sGather6");
        }

        return yjxsGatherService.getstoreTag2(sGather, pageNum, pageSize);
    }

    //    出库登记 把出库表库存标志为已调度（2）的数据查询出来
    @GetMapping("getspaystoreTag2")
    public PageVo<SPay> getspaystoreTag2(SPay sPay, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sPay != null) {
            request.getSession().setAttribute("sPay3", sPay);
        } else {
            sPay = (SPay) request.getSession().getAttribute("sPay3");
        }

        return yjxsPayService.getspaystoreTag2(sPay, pageNum, pageSize);
    }


    //    入库登记复核 把入库表库存标志为已登记（3）的数据查询出来
    @GetMapping("getstoreTag3")
    public PageVo<SGather> getstoreTag3(SGather sGather, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        User loginUser = (User) request.getSession().getAttribute("loginUser");
        if (loginUser.getRole().getRoleId()==4){
            return null;
        }
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sGather != null) {
            request.getSession().setAttribute("sGather7", sGather);
        } else {
            sGather = (SGather) request.getSession().getAttribute("sGather7");
        }

        return yjxsGatherService.getstoreTag3(sGather, pageNum, pageSize);
    }

    //    出库登记复核 把出库表库存标志为已登记（3）的数据查询出来
    @GetMapping("getspaystoreTag3")
    public PageVo<SPay> getspaystoreTag3(SPay sPay, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        User loginUser = (User) request.getSession().getAttribute("loginUser");
        if (loginUser.getRole().getRoleId()==4){
            return null;
        }
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sPay != null) {
            request.getSession().setAttribute("sPay7", sPay);
        } else {
            sPay = (SPay) request.getSession().getAttribute("sPay7");
        }

        return yjxsPayService.getspaystoreTag3(sPay, pageNum, pageSize);
    }


    ////点击调度 根据产品id查询 库存单元表 该商品的当前剩余存储量
    @GetMapping("querysCellCurrentAmount")
    public Integer querysCellCurrentAmount(String productId) {
        return yjxsCellService.ByProduceIdquerysCellCurrentcAmount(productId);
    }

    // 查询当前储存量  出库时不可大于 出库量不可大于当前储存量
    @GetMapping("querySpaysCellCurrentAmount")
    public Integer querySpaysCellCurrentAmount(String productId) {
        return yjxsCellService.querySpaysCellCurrentAmount(productId);
    }

    //入库登记
    //通过入库明细id 修改该id下的确认入库件数 （gathered_amount）

    /**
     * @param id             明细表id数组
     * @param gatheredAmount 入库数量数组
     * @param parentId       该明细表的父id
     * @return
     */
    @GetMapping("ByGatherDetailsIdupdatesgatheredAmount")
    public Integer ByGatherDetailsIdupdatesgatheredAmount(Integer[] id, Integer[] gatheredAmount, Integer parentId) {
        Integer sumAmount = 0; //确认总数量
        for (int i = 0; i < id.length; i++) {
            sumAmount += gatheredAmount[i];
            // System.out.println("产品id=="+id[i]+"确认入库数量=="+gatheredAmount[i]);
            //根据 明细id 修改确认入库数量
            int n = yjXsGatherDetails.ByGatherDetailsIdupdatesgatheredAmount(id[i], gatheredAmount[i]);
        }
        //根据parentId  和 sumAmount 修改入库表的总确认数量  并且把库存标志（store_tag）改为 已登记（3）
        int m = yjxsGatherService.ByGatherIdupdatesgatheredAmount(parentId, sumAmount);
        return m;
    }


    //出库登记
    @GetMapping("BysPayDetailsIdupdatesgatheredAmount")
    public Integer BysPayDetailsIdupdatesgatheredAmount(Integer[] id, Integer[] gatheredAmount, Integer parentId) {
        Integer sumAmount = 0; //确认总数量
        for (int i = 0; i < id.length; i++) {
            sumAmount += gatheredAmount[i];
            // System.out.println("产品id=="+id[i]+"确认入库数量=="+gatheredAmount[i]);
            //根据 明细id 修改确认出库数量
            int n = yjXsPayDetailsServicel.BysPayDetailsIdupdatesgatheredAmount(id[i], gatheredAmount[i]);
        }
        //根据parentId  和 sumAmount 修改出库表的总确认数量  并且把库存标志（store_tag）改为 已登记（3）
        int m = yjxsPayService.ByspayIdupdatesgatheredAmount(parentId, sumAmount);
        return m;
    }


    //入库登记
    //通过入库明细id 修改该id下的确认入库件数 （gathered_amount）

    /**
     * @param id             明细表id数组
     * @param gatheredAmount 入库数量数组
     * @param parentId       该明细表的父id
     * @return
     */
    @GetMapping("ByGatherDetailsIdupdatesgatheredAmountchecker")
    public Integer ByGatherDetailsIdupdatesgatheredAmountchecker(Integer[] id, Integer[] gatheredAmount, Integer parentId) {
        Integer sumAmount = 0; //确认总数量
        for (int i = 0; i < id.length; i++) {
            sumAmount += gatheredAmount[i];
            // System.out.println("产品id=="+id[i]+"确认入库数量=="+gatheredAmount[i]);
            //根据 明细id 修改确认入库数量
            int n = yjXsGatherDetails.ByGatherDetailsIdupdatesgatheredAmount(id[i], gatheredAmount[i]);
        }
        //根据parentId  和 sumAmount 修改入库表的总确认数量  并且把库存标志（store_tag）改为 已登记（3）
        int m = yjxsGatherService.ByGatherIdupdatesgatheredAmount(parentId, sumAmount);
        //判断是否为复核
        //往入库表修改值  添加 复核人和复核时间
        SGather sGather = new SGather();
        sGather.setId(parentId);
        yjxsGatherService.updatecheckerAndcheckTime(sGather);
        //int aa = yjxsCellService.addAmount(addAmount,productId);
        return m;
    }


    //出库登记复核  通过复核
    //通过入库明细id 修改该id下的确认入库件数 （gathered_amount）

    /**
     * @param id             明细表id数组
     * @param gatheredAmount 出库数量数组
     * @param parentId       该明细表的父id
     * @return
     */
    @GetMapping("ByspayDetailsIdupdatesgatheredAmountchecker")
    public Integer ByspayDetailsIdupdatesgatheredAmountchecker(Integer[] id, Integer[] gatheredAmount, Integer parentId) {
        //System.out.println("父id-------"+parentId);
        Integer sumAmount = 0; //确认总数量
        for (int i = 0; i < id.length; i++) {
            sumAmount += gatheredAmount[i];
            //System.out.println("产品id=="+id[i]+"确认入库数量=="+gatheredAmount[i]);
            //根据 明细id 修改确认入库数量
            int n = yjXsPayDetailsServicel.ByspayDetailsIdupdatesgatheredAmountchecker(id[i], gatheredAmount[i]);
        }
        //根据parentId  和 sumAmount 修改出库表的总确认数量  并且把库存标志（store_tag）改为 已复核（4）
        int m = yjxsPayService.ByspayIdupdatesgatheredAmountandstoreTag4(parentId, sumAmount);
        //判断是否为复核
        //往入库表修改值  添加 复核人和复核时间
        SPay sPay = new SPay();
        sPay.setId(parentId);
        yjxsPayService.updatecheckerAndcheckTime(sPay);
        return m;
    }


    /**
     * parentId  出库表id
     *
     * @return
     */
    //根据出库表id查询 该id下的细节表
    @GetMapping("byParentIdquerysPayDetailspayTag2")
    public List<SPayDetails> byParentIdquerysPayDetailspayTag2(Integer id) {
        //System.out.println("出库表父id-----"+id);
        return yjXsPayDetailsServicel.ByparentIDquerypayTag2(id);
    }

    //出库复核 点击复核
    //通过入库表id  查询该id 下的细节表 gather_tag标记为已调度（gather_tag=2）的数据
    @GetMapping("ByspayIdquerysGatherDetailsgatherTag2")
    public List<SPayDetails> ByspayIdquerysGatherDetailsgatherTag2(Integer id) {
        //System.out.println("id====="+id);
        return yjXsGatherDetails.ByspayIdquerysGatherDetailsgatherTag2(id);
    }


    //入库查询
    @GetMapping("getGatherstoreTagGreater2")
    public PageVo<SGather> getGatherstoreTagGreater2(SGather sGather, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        //System.out.println("sGather===="+sGather);
        //System.out.println(pageNum+",,"+pageSize);
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sGather != null) {
            request.getSession().setAttribute("sGather12", sGather);
        } else {
            sGather = (SGather) request.getSession().getAttribute("sGather12");
        }

        return yjxsGatherService.getGatherstoreTagGreater2(sGather, pageNum, pageSize);
    }

    @GetMapping("getSpaystoreTagGreater2")
    public PageVo<SPay> getAllSgetSpaystoreTagGreater2Pay(SPay sPay, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        //System.out.println("sPay===="+sPay);
        //System.out.println(pageNum+",,"+pageSize);
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sPay != null) {
            request.getSession().setAttribute("sPay13", sPay);
        } else {
            sPay = (SPay) request.getSession().getAttribute("sPay13");
        }

        return yjxsPayService.getAllSgetSpaystoreTagGreater2Pay(sPay, pageNum, pageSize);
    }

    //查询库存单元表
    @GetMapping("getAllSCell")
    public PageVo<SCell> getAllSCell(SCell sCell, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        //System.out.println("库存单元对象---"+sCell);
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        if (sCell != null) {
            request.getSession().setAttribute("sCell", sCell);
        } else {
            sCell = (SCell) request.getSession().getAttribute("sCell");
        }

        return yjxsCellService.getAllSCell(sCell, pageNum, pageSize);
    }

    @GetMapping("BysGatherIdquerysGatherDetails2")
    public List<SGatherDetails> BysGatherIdquerysGatherDetails2(Integer id) {
        return yjXsGatherDetails.ByparentIDquery2(id);
    }

    @GetMapping("BySpayIdqueryspayDetails2")
    public List<SPayDetails> BySpayIdqueryspayDetails2(Integer id) {
        return yjXsPayDetailsServicel.BySpayIdqueryspayDetails2(id);
    }

    //查看是否已配置安全库存
    @GetMapping("ByproductIdqueryIsdesignCellTag2")
    public int ByproductIdqueryIsdesignCellTag2(String productId) {
//        String n = yjxdFileService.ByproductIdqueryDesignCellTag(productId);
//        return Integer.parseInt(n);
        //查询库存单元表 该产品是否配置安全库存
       String n = yjxsCellService.byProductIdqueryChecktag(productId);
        if(n==null){
            n="-1";
        }
        System.out.println(n);
        return Integer.parseInt(n);
    }

}
